package com.coderfans.logwrapper;

import org.apache.commons.logging.Log;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import java.util.Properties;

/**
 * Created by ${fanchunshuai} on 2016-11-15.
 *
 * @version: V1.0
 * @Desc:
 * @Copyright (c) 2016 58到家-版权所有
 */
public class LogUtils {
    private static Logger logger = null;
    /**
     * 获取封装的Logger
     * @param clazz
     * @return
     */
    public static  Logger getLogger(Class clazz){
        Properties prop = new Properties();
        prop.setProperty("log4j.rootLogger", "DEBUG, CONSOLE");
        prop.setProperty("log4j.appender.CONSOLE", "org.apache.log4j.ConsoleAppender");
        prop.setProperty("log4j.appender.CONSOLE.layout", "org.apache.log4j.PatternLayout");
        prop.setProperty("log4j.appender.CONSOLE.layout.ConversionPattern", "%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] %-5p %C{1} : %m%n");
        PropertyConfigurator.configure(prop);
        logger = Logger.getLogger(clazz.getClass());
        return logger;
    }
}
